<!DOCTYPE html>
<html lang="en">

<head>
    <title>Login</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>


</head>

<body>


<div class="container">
    <div class="container" style="margin-top:150px">
        <div class="row">
            <div class="col-sm"></div>
            <div class="col-sm">
                <div class="card card-primary">
                    <div class="card-header">
                        <h4>系统</h4>
                    </div>

                    <div class="card-body">
                        <form method="POST" action=" " class="needs-validation">
                            {% csrf_token %}
                            <div class="form-group">
                                <label for="username">用户名</label>
                                <input id="username" type="username" class="form-control" name="username"
                                       tabindex="1" required autofocus>
                                <div class="invalid-feedback">
                                    Please fill in your username
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="password" class="d-block">密码
                                </label>
                                <input id="password" type="password" class="form-control" name="password"
                                       tabindex="2" required>
                                <div class="invalid-feedback">
                                    please fill in your password
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="d-block">验证码
                                </label>
                                <label class="d-block">{{ user_login_from.captcha}}
                                </label>
                            </div>


                            <div class="form-group">
                                <button type="submit" class="btn btn-primary btn-block" tabindex="4">
                                    登录
                                </button>
                            </div>
                            <div class="error btns" id="jsEmailTips">
                                <div>
                                    {{ msg }}
                                </div>
                                {% for key, error in user_login_from.errors.items %}
                                {{ error }}
                                {% endfor %}

                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col-sm"></div>
        </div>
        <br>
    </div>
</div>


</body>

<script>
    // # ajax 刷新
    $('.captcha').click(function () {
        console.log('click');
        $.getJSON("/captcha/refresh/",
            function (result) {
                $('.captcha').attr('src', result['image_url']);
                $('#id_captcha_0').val(result['key'])
            });


    });

</script>

</html>